package com.xugui.learn.pay.pojo.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 关闭订单响应参数
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CloseResponse implements Serializable {

    /**
     * 是否成功
     */
    private Boolean success;

    /**
     * 订单号
     */
    private String orderNo;

    /**
     * 错误码
     */
    private String errorCode;

    /**
     * 错误信息
     */
    private String errorMsg;

    /**
     * 通过订单号返回一个关闭订单成功的响应参数
     *
     * @param orderNo 订单号
     * @return 关闭订单成功的响应参数
     */
    public static CloseResponse success(String orderNo) {
        CloseResponse response = new CloseResponse();
        response.setSuccess(true);
        response.setOrderNo(orderNo);
        return response;
    }

    /**
     * 通过错误码和错误信息返回一个关闭订单失败的响应参数
     *
     * @param errorCode 错误码
     * @param errorMsg  错误信息
     * @return 关闭订单失败的响应参数
     */
    public static CloseResponse failure(String errorCode, String errorMsg) {
        CloseResponse response = new CloseResponse();
        response.setSuccess(false);
        response.setErrorCode(errorCode);
        response.setErrorMsg(errorMsg);
        return response;
    }
}